﻿using GetMan.Core.Common;
using GetMan.Core.DB.Entities;
using GetMan.Core.DB.Services.Request;
using GetMan.Core.infrastructure.BaseC;
using Rubyer;
using Rubyer.Models;
using System;
using System.ComponentModel.Composition;

namespace GetMan.ViewModels
{
    [Export(typeof(RequestViewModel))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class RequestViewModel : ViewModelBase<RequestViewModel>, IDialogDataContext
    {
        [Import]
        private IRequestService requestService;

        public RequestViewModel() : base()
        {

        }

        ~RequestViewModel()
        {

        }

        private string title;
        public string Title
        {
            get => title;
            set
            {
                title = value;
                NotifyOfPropertyChange(() => Title);
            }
        }



        public event Action<object> RequestClose;
        public void OnDialogOpened(object parameters)
        {
            var @params = (IParameters)parameters;

        }

        #region 事件
        public void Save()
        {

        }

        public void Close(bool isRefresh, RequestEntity model = null)
        {
            var parameters = new Parameters();
            //是否刷新
            parameters.Add(DialogCommanKeys.Refresh, isRefresh);
            parameters.Add(DialogCommanKeys.Model, model);
            this.RequestClose?.Invoke(parameters);
        }
        public void Close()
        {
            this.Close(false, null);
        }
        #endregion
    }
}